package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class CustomerTransfer {
    private Long id;

    private Customer customer;

    private Employee transUser;

    private Date transTime;

    private Employee oldSeller;

    private Employee newSeller;

    private String transReason;

    public String getJsonData(){
        Map<String,Object> data = new HashMap<>();
        data.put("id",this.getId());
        data.put("customerId",this.getCustomer().getId());
        data.put("customerName",this.getCustomer().getName());

        data.put("transUserId",this.getTransUser().getId());
        data.put("transUserName",this.getTransUser().getName());

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String transTime = simpleDateFormat.format(this.transTime);
        data.put("transTime",transTime);

        data.put("oldSellerId",this.getOldSeller().getId());
        data.put("oldSellerName",this.getOldSeller().getName());

        data.put("newSellerId",this.getNewSeller().getId());
        data.put("newSellerName",this.getNewSeller().getName());

        data.put("transReason",this.getTransReason());

        return JSON.toJSONString(data);
    }
}